typedef int TYPE;

typedef struct _ctl_dlist_TYPE_node {
  struct _ctl_dlist_TYPE_node* prev;
  struct _ctl_dlist_TYPE_node* next;
  TYPE value;
} ctl_dlist_TYPE_node;

typedef struct {
  ctl_dlist_TYPE_node* head;
  ctl_dlist_TYPE_node* tail;
} ctl_dlist;

ctl_res_ctl_dlist_TYPE_node ctl_dlist_TYPE_new_node(TYPE data) {
  ctl_res_ctl_dlist_TYPE_node res = {0};
  ctl_dlist_TYPE_node* node  = (ctl_dlist_TYPE_node *)malloc(sizeof(ctl_dlist_TYPE_node));
  CHECK_COND_RET_RES(node != NULL, EOOM, res);
  node->next = NULL;
  node->prev = NULL;
  res.value = node;
  return res;
}

ctl_res_void ctl_dlist_TYPE_free_node(TYPE data)
{
    ctl_dlist_TYPE_node* node  = (ctl_dlist_TYPE_node *)malloc(sizeof(ctl_dlist_TYPE_node));
    CHECK_COND_RET_RES(node != NULL, EOOM, res);
    node->next = NULL;
    node->prev = NULL;
    return node;
}
